@layout("/common/_container.html"){
<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8"/>
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <input type="hidden" id="id" value="${id}">
        <input type="hidden" id="customerPhone" value="${customerPhone}">
        <div>正在呼出······${customerPhone}</div>
        <div>请稍后···</div>
    </div>
    <div>
        <button onclick="hangup()" type="button" class="btn">挂断</button>
        <button onclick="closehangup()" type="button" class="btn">取消</button>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: parent.parent.document.getElementById("whurl").value,
            type: "get",
            data: {
                "op": "callout",
                "Exten":parent.parent.document.getElementById("exten").value,
                "phone": document.getElementById("customerPhone").value.substring(0,11),
                "flowid": document.getElementById("id").value
            },
            success: function (data) {
                Feng.success('呼出成功!请准备··');
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            }
        })
    });

    function hangup() {
        $.ajax({
            url: parent.parent.document.getElementById("whurl").value,
            type: "get",
            data: {
                "op": "onhook",
                "Exten":parent.parent.document.getElementById("exten").value
            },
            success: function (data) {
                if(data==100){
                    Feng.success('挂断成功!');
                } else if(data==101){
                    Feng.success('分机号不存在!');
                } else if(data==103){
                    Feng.success('参数错误!');
                } else if(data==500){
                    Feng.success('其他错误!');
                }
            }
        })
    }

    function closehangup() {
        hangup();
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    }
</script>
@}